using System;
using System.Collections;
using System.Collections.Generic;
using Base;
using FairyGUI;
using Unity.VisualScripting.Dependencies.NCalc;
using UnityEngine;
using Random = UnityEngine.Random;

public class BaseMainUI : MonoBehaviour
{
    private UI_BaseMain ui;
    private void Awake()
    {
        BaseBinder.BindAll();
        UIPackage.AddPackage("Assets/Fgui/Resources/UI/Base");
        ui = UI_BaseMain.CreateInstance();
    }
    private void Start()
    {
        GRoot.inst.AddChild(ui);
        ui.m_listcards.numItems = 8;
        ui.m_listcards.itemRenderer = CardRenderer;
    }

    private void RamCard()
    {
        int num= Random.Range(1, 15);
    }
    
    
    private void CardRenderer(int index, GObject item)
    {
        var obj = item as UI_puke;
        if(obj==null)return;
        obj.onClick.Set(PukeOnClick);
    }

    private void PukeOnClick(EventContext context)
    {
       var obj = context.data as UI_puke;
       obj.m_open.SetHook("change",ChangeCard);
       obj.m_open.Play();
    }
}
